package cn.fantasy.thread;

/**
 * @author ET
 * @description 1. 使用线程的join方法
 * @date 2023/3/10 14:38
 * @Version V1.0
 */
public class ThreadOrderOne {
    public static void main(String[] args) {
        final Thread thread1 = new Thread(() -> {
            System.out.println("one");
        });

        final Thread thread2 = new Thread(() -> {
            try {
                thread1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("two");
        });

        final Thread thread3 = new Thread(() -> {
            try {
                thread2.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("three");
        });

        thread1.start();
        thread2.start();
        thread3.start();
    }
}
